using System.Web.UI;

namespace PropertyExpression.TypedDataBinding.Web
{
    public class BinderBase
    {
        protected interface IControlBinder
        {
            void ToModel(Control control);
            void FromModel(Control control);
        }

        protected class ControlBinderWrapper<TControl> : IControlBinder where TControl : Control
        {
            private readonly IControlBinder<TControl> controlBinder;

            public ControlBinderWrapper(IControlBinder<TControl> controlBinder)
            {
                this.controlBinder = controlBinder;
            }

            public void ToModel(Control control)
            {
                controlBinder.ToModel((TControl)control);
            }

            public void FromModel(Control control)
            {
                controlBinder.FromModel((TControl)control);
            }
        }
    }
}